package com.tomtop.core.web.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.session.Session;
import org.springframework.session.SessionRepository;
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

@Configuration
@ConditionalOnClass(SessionRepository.class)
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=1800)
public class SessionConfig {
	@Bean <S extends Session > SessionRepository<?> sessionRepository(RedisTemplate<Object, Object> redisTemplate){
		RedisOperationsSessionRepository sessionRepository=new RedisOperationsSessionRepository(redisTemplate);
		return sessionRepository;
	}
}
